package study;


import java.util.Arrays;
import java.util.Scanner;

public class NumSort {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int[] a = new int[1];
        int j = 0;
        while (cin.hasNext()) {
            if (j == a.length) {//倍增容量 logn/n
                // System.out.println("--double capacity now--");
                int[] a2 = new int[a.length * 2];
                System.arraycopy(a, 0, a2, 0, a.length);
                a = a2;
            }
            a[j++] = cin.nextInt();
        }
        for (int i = 0; i < j; i++) {
            System.out.print(a[i] + " ");
        }
        System.out.println();
        Arrays.sort(a, 0, j);
        System.out.print(a[0]);
        int recent = a[0];
        for (int i = 1; i < j; i++) {
            if (a[i] == recent) {
                continue;
            }
            System.out.print(" " + a[i]);
            recent = a[i];
        }
        System.out.println();
    }

   /* public static void main(String[] args) {
        int[] a = new int[1];
        int i = 0;
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            for (; i < a.length; i++) {
                a[i] = in.nextInt();
            }
            if (i == a.length) {
                int[] a2 = new int[2 * a.length];
                System.arraycopy(a,0,a2,0,a.length);
                a = a2;
            }
            Arrays.sort(a, 0, i);
            int rescent = a[0];
            for (int x : a) {
                if (x == rescent) continue;
                System.out.print(x+" ");
                rescent = x;
            }
        }
    }

    */
}
